home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / NONPORT.ZIP / RESIZE.C < prev    next >
Text File  |  1992-11-21  |  4KB  |  127 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3. #undef resize
  4.  
  5. #ifndef NDEBUG
  6. char *rcsid_resize = "$Header: c:/curses/nonport/RCS/resize.c%v 2.0 1992/11/15 03:18:27 MH Rel $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   resize()     - Resizes PDCurses; Changes video text size if necessary.
  15.  
  16.   PDCurses Description:
  17.        Does necessary initializations for the PDCurses package when
  18.        doing screen size changes. The user is responsible for
  19.        deleting and/or resizing windows after this call is made.
  20.  
  21.        See the call _resize_win().
  22.  
  23.        WARNING: This routine deallocated the existing stdscr, curscr
  24.        and modifies LINES, COLS and other internal PDCurses
  25.        variables.
  26.  
  27.   PDCurses Return Value:
  28.        The resize() function returns OK on success and ERR on error.
  29.  
  30.   PDCurses Errors:
  31.        It is an error to call this function before calling initscr().
  32.        Also, an error will be generated if we fail to create a newly
  33.        sized replacement window for _cursvar.tmpwin, curscr, or stdscr.
  34.        This will typically happen when increasing the window size.
  35.  
  36.        NOTE:  If this happens, the previously successfully allocated
  37.        windows are left alone.  i.e. The resize is NOT cancelled for
  38.        those windows.
  39.  
  40.   PDCurses BUGS:
  41.  
  42.        At this time, there is no support for any 40-column screen modes.
  43.  
  44.   Portability:
  45.        PDCurses        int     resize( int newlines );
  46.  
  47. **man-end**********************************************************************/
  48.  
  49. int    resize(int newlines)
  50. {
  51.        WINDOW* tmp;
  52.  
  53.        if (stdscr == (WINDOW *)NULL)
  54.                return(ERR);
  55.  
  56. #ifdef FLEXOS
  57.        /*
  58.         * Under FlexOS, this is functionally equivalent to a recallable
  59.         * initscr() because FlexOS does not yet support determination of
  60.         * screen fonts and therefore font loading and therefore text mode
  61.         * screen resolution changes...
  62.         */
  63.        return( ERR );
  64. #endif
  65. #if !defined(OS2)
  66.        switch (_cursvar.adapter)
  67.        {
  68.        case _EGACOLOR:
  69.                if (newlines >= 43)             PDC_set_font(_FONT8);
  70.                else                            PDC_set_80x25();
  71.                break;
  72.  
  73.        case _VGACOLOR:
  74.                if      (newlines > 28)         PDC_set_font(_FONT8);
  75.                else    if (newlines > 25)      PDC_set_font(_FONT14);
  76.                else                            PDC_set_80x25();
  77.                break;
  78.  
  79.        default:
  80.                break;
  81.        }
  82. #endif
  83. #ifdef     OS2
  84.        if (newlines >= 43)             PDC_set_font(_FONT8);
  85.        else    if (newlines > 25)      PDC_set_font(_FONT14);
  86.        else                            PDC_set_80x25();
  87. #endif
  88.        _cursvar.lines = LINES = PDC_get_rows();
  89.        _cursvar.cols  = COLS  = PDC_get_columns();
  90.  
  91.        if (curscr->_pmaxy > LINES)
  92.        {
  93.                PDC_scroll(0, 0, curscr->_pmaxy - 1, COLS - 1, 0, _cursvar.orig_attr);
  94.        }
  95.        else
  96.        {
  97.                PDC_scroll(0, 0, LINES - 1, COLS - 1, 0, _cursvar.orig_attr);
  98.        }
  99.        if ((tmp = resize_win(tmpwin, LINES, COLS)) != (WINDOW *) NULL)
  100.        {
  101.                tmpwin = tmp;
  102.        }
  103.        else
  104.        {
  105.                return (ERR);
  106.        }
  107.        if ((tmp = resize_win(curscr, LINES, COLS)) != (WINDOW *) NULL)
  108.        {
  109.                curscr = tmp;
  110.        }
  111.        else
  112.        {
  113.                return (ERR);
  114.        }
  115.        if ((tmp = resize_win(stdscr, LINES, COLS)) != (WINDOW *) NULL)
  116.        {
  117.                stdscr = tmp;
  118.                touchwin(stdscr);
  119.                wnoutrefresh(stdscr);
  120.        }
  121.        else
  122.        {
  123.                return (ERR);
  124.        }
  125.        return (OK);
  126. }
  127.